﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SegmentDisplay.Common
{
    public class ValueSetBase<T>
    {
        public static Dictionary<string, T> Alphabet {get; protected set;} 

        static ValueSetBase()
        {
            Alphabet = new Dictionary<string, T>();
            InitializeSet();
        }

        public static void InitializeSet() { }
        
        public static void AddValue(string simbol, T value)
        {
            Alphabet.Add(simbol, value);
        }

        public static T GetValue(string simbol)
        {
            T result = default(T);
            if(!string.IsNullOrEmpty(simbol))
            {
                string invariant = simbol.Trim();
                if (invariant.Length == 1)
                    Alphabet.TryGetValue(invariant, out result);
            }
            return result;
        }
    }
}
